from pyboot.utils.db import db


def insert_operation_list(data):
    sql = """ 
        INSERT INTO ey_operation_shop(shop_id, operation_user_id, customer_service_user_id, back_phone, address, platform_id) VALUES 
    """
    for item in data:
        sql = sql + str(tuple(item))
        sql = sql + ","
    sql = sql[:-1]
    print(sql)
    db.execute(sql)


def get_phone_by_platform_and_shop(platform_name, shop_name):
    sql = """
        SELECT back_phone FROM ey_operation_shop WHERE platform_id = (SELECT id FROM ey_platform WHERE name = '{platform_name}') AND shop_id = (SELECT id FROM ey_shop WHERE name = '{shop_name}')
    """.format(platform_name=platform_name, shop_name=shop_name)
    return db.fetch_all(sql)
